<template>
	<div class="top" style="display: flex;">
    <div style="background: rgb(255, 255, 255); border-radius: 25px; height: 50px; padding: 6px 12px 6px 6px; margin-right: 30px;">
      <div class="flexbc">
        <div class="flex">
          <div style="margin-right: 5px;"><img  src="../../static/img/chat.png" style=" width: 38px; height: 38px; border-radius: 19px;"/></div>
          <div>
            <div style=" font-size: 14px;color: #020C1D;">客服平台</div>
            <div style=" font-size: 12px;color:#787D85;">待回复:<span style="color: #FF0000;">{{ count }}</span></div>
          </div>
        </div>
        <div @click="joinchatlist" class="t_join_chatlist">进入</div>
      </div>
    </div>

    <div style="background: rgb(255, 255, 255); border-radius: 25px; height: 50px; padding: 6px 12px 6px 6px; width: 180px;">
      <div class="flexbc">

        <div class="flex">
          <div style="margin-right: 5px;"><img  src="../../static/img/toux.png" style=" width: 38px; height: 38px; border-radius: 19px;"/></div>
          <div>
            <div style=" font-size: 14px;color: rgb(120, 125, 133);">{{user.name}}</div>
            <div style=" font-size: 12px;color: rgb(120, 125, 133);">管理员</div>
          </div>
        </div>
        <div>
          <el-dropdown @command="handleCommand" trigger="click" >
            <span class="el-dropdown-link">
              <i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="a">退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </div>
    </div>

    <el-dialog  title="请先系统配置" :visible.sync="weipeizhi" center :close-on-click-modal="false" :modal-append-to-body="false" width="600px">
      <div class="flexcc">您还未完成系统配置，系统暂不可用，请先前往配置</div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="go('/xitongpeizhi')">确定</el-button>
      </span>
    </el-dialog>

	</div>
</template>

<script>
	export default {
		name: 'top',
		data() {
			return {
        user:"",
        count:0,
        icp:"",
        weipeizhi:false
			}
		},
		created() {

      //获取客服数
      this.getcountkf()
      this.icp = localStorage.getItem('icp')
		},
		mounted() {
      if(localStorage.getItem('user')){
        this.user = JSON.parse(localStorage.getItem('user'))
      }
		},
		methods: {
      handleCommand:function(e){
        if(e == 'a'){
          axios.post('/own/auth/logout').then((response)=>{
          	if (response.data.msg.code == 0) {
          		this.$router.push('/login')
          	} else {
          		this.$message.error(response.data.msg.info);
          	}
          })
        }
      },
      joinchatlist(){
        this.$router.push({path:'/kefu/kfset'})
      },
      //获取客服数
      getcountkf(){
        axios.get('/own/customer/service/count').then((response)=>{
          	if (response.data.msg.code == 0) {
              console.log('获取客服数')
              console.log(response.data.data.count)
          		this.count = response.data.data.count
          	} else {
          		this.$message.error(response.data.msg.info);
          	}
          })
      },
      getpeizhi:function(){

        axios.get('/own/system/get').then((response)=>{
        	if (response.data.msg.code == 0) {
            if(!response.data.data.shop_name || !response.data.data.sms_sign || !response.data.data.gth_id){
              if(this.$router.history.current.fullPath != '/xitongpeizhi'){
                this.weipeizhi = true
              }
            }
        	} else {
        		this.$message.error(response.data.msg.info);
        	}
        })

      },
		}
	}
</script>


<style scoped>
  /deep/ .el-radio{ display: block; margin-bottom: 20px;}
  .t_join_chatlist{
    background-color: #E0F8E2;
    font-size: 13px;
    color: #0E9D0E;
    width: 75px;
    text-align: center;
    line-height: 30px;
    border-radius: 15px;
    margin-left: 10px;
    cursor: pointer;
  }
</style>
